package webapp.backOffice.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import modele.utilisateur.Admin;
import dao.utilisateur.AdminDAO;

/**
 * Servlet implementation class Init
 */
@WebServlet("/admin/init")
public class Init extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		Admin admin = new Admin();
		admin.setLogin("admin");
		admin.setMdp("admin");
		
		AdminDAO adminDAO = AdminDAO.getDAO();
		if (adminDAO.retrieveAll().size() == 0)
		{
			adminDAO.create(admin);
			response.getWriter().print("Done. Account admin/admin created");
		}
	}


}
